1. Field of the Invention
This invention relates to a method, apparatus and program storage device for enabling the reading of data from a named pipe in an information handling system while minimizing the use of system resources.
2. Description of the Related Art
One mechanism for passing data from a first process to a second process in an information handling system is a FIFO list called a “named pipe”. (i.e. created via mkfifo( ) function call). A named pipe is a data stream that programs read and write data to and from. Thus, FIG. 1 shows an information handling system 100 in which a client process 102 writes to a named pipe 104 by issuing a write( ) function call to the application program interface (API) of the operating system (OS) 108, while a server process 106 reads from the same pipe 104 by issuing a read( ) function call to the operating system 108. Named pipes, also referred to as FIFOs, are described in W. R. Stevens, UNIX Network Programming, volume 2 (2d ed. 1998) (Stevens I), at pages 54-66.
A named pipe application can run in either blocking or non-blocking mode. When running in blocking mode, if a read( ) function call is issued, all of the system resources 110 (FIG. 1) related to the reading process 106 are suspended in the system until another application (e.g., client 102) writes to the pipe 104 and unblocks the reading process (106), as described in W. R. Stevens, Advanced Programming in the UNIX Environment (1993) (Stevens II), at pages 445-449.
In the perfect world a computer operating system (OS) has unlimited amount of system resources such as random access memory (RAM) and CPU cycles. Unfortunately, as the amount of system resources increase through technological advancements so do the demands. One reason for the increased demand on system resources is the diverse number of applications that execute in the operating system—many of those applications are client/server applications sending/receiving data via named pipes.
The time between the read and write sequences can be long and far between. If the application 106 is running in non-blocking mode and a read( ) function call is issued, the application may or may not have data to read. If no data is available, a polling method is used for read( ). This means that a read( ) function call is issued every so often to determine if there is data to be read or a select( ) function is used to wake up the process when the data becomes available, as described in Stevens II at pages 396-402. This also ties up the resources the process uses while it is active in the system. In a high-performance transaction-oriented system, it is possible to have many processes active in the system currently suspended due to a named pipe read( ) function call. All the suspended processes can drain the system of the valuable resources needed to dispatch additional processes and preclude any new processes from being dispatched.
On certain operating systems the memory (virtual resource allocated to a process) required by the application is managed by the operating system. And even though the resources are virtual and managed by the operating system, they are still backed against real resources. When managing the resources the operating system has a certain overhead cost that must be taken into account. For example if it is memory and the amount of real memory is not available to back a new application virtual memory requirement, the OS “swaps” another process's virtual memory out of real memory and maps it the new requesting application virtual memory address, as described in A. Silberschatz and J. L. Peterson, Operating System Concepts (alternate ed. 1988), at pages 244-264. Thrashing may occur if enough requests arrive requiring greater memory than the available amount of real memory, as described in the same reference at pages 297-302. Furthermore, some operating systems do not offer the preemptive paging that allows for swapping another process's virtual memory. Hence, on those operating systems, the new memory requirement could not be fulfilled until another process voluntarily releases it.
What is desired, therefore, is a mechanism for enabling the reading of data from a named pipe without devoting scarce system resources to a reader process for which there is no data.